package com.wzy.orderSystem.controller;

import com.wzy.orderSystem.pojo.is_role;
import com.wzy.orderSystem.service.impl.opIsRoleImpl;

import java.sql.SQLException;
import java.util.List;

public class roleController {
    private static opIsRoleImpl orl = new opIsRoleImpl();

    //根据角色id 查询角色信息
    public static void selectById(int id) throws SQLException {
        List<is_role> is_roles = orl.selectById(id);
        for(is_role r: is_roles){
            System.out.println("角色id为"+id+"的信息如下：");
            System.out.println("角色id为："+r.getId());
            System.out.println("角色名为："+r.getRoleName());
        }
    }

    //根据角色id修改角色名
    public static void updateById(int id,String roleName){
        int i = orl.updateById(id, roleName);
        System.out.println(i>0?"修改成功！":"修改失败");
    }

    //根据角色id删除角色
    public static void deleteById(int id){
        int i = orl.deleteById(id);
        System.out.println(i>0?"删除成功！":"删除失败");
    }

    //增加角色
    public static void insert(int id, String roleName){
        int i = orl.insert(id,roleName);
        System.out.println(i>0?"新增成功！":"新增失败");
    }
}